<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<script>
description("Test what happens when you set the window's prototype to various values.");

var originalWindowPrototype = __proto__;
var chainPointingBackToWindow = { __proto__: window };
var anotherObject = { };
var error = "'TypeError: Immutable prototype object \\'#<Window>\\' cannot have their prototype set'";

shouldThrow("__proto__ = window; __proto__", error);
shouldThrow("__proto__ = chainPointingBackToWindow; __proto__", error);
shouldBe("__proto__ = 1; __proto__", "originalWindowPrototype");
shouldBe("__proto__ = 'a string'; __proto__", "originalWindowPrototype");
shouldThrow("__proto__ = anotherObject; __proto__", error);
shouldBe("anotherObject.__proto__ = window; __proto__", "originalWindowPrototype");
shouldBe("__proto__ = 1; __proto__", "originalWindowPrototype");
shouldBe("__proto__ = 'a string'; __proto__", "originalWindowPrototype");
shouldThrow("__proto__ = anotherObject; __proto__", error);
shouldBe("__proto__ = originalWindowPrototype; __proto__", "originalWindowPrototype");
shouldBe("anotherObject.__proto__ = window; anotherObject.__proto__", "window");
shouldThrow("__proto__ = null; __proto__", error);
shouldThrow("location.__proto__.__proto__ = location", "'TypeError: Immutable prototype object \\'#<Location>\\' cannot have their prototype set'");
</script>
</body>
</html>
